﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Reports
{
    /// <summary>
    /// Implementation of IReportServerCredentials to supply forms credentials to SQL Reporting using GetFormsCredentials() 
    /// </summary>
    using Microsoft.Reporting.WebForms;
    using System.Security.Principal;
    using System.Configuration;
    using System.Net;
    public class ReportServerCredentials : IReportServerCredentials
    {
        private string _userName;
        private string _password;
        private string _domain;

        public ReportServerCredentials(string userName, string password, string domain)
        {
            _userName = userName;
            _password = password;
            _domain = domain;
        }

        public WindowsIdentity ImpersonationUser
        {
            get
            {
                return null;
            }
        }

        public ICredentials NetworkCredentials
        {
            get
            {
                return null;
            }
        }

        public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
        {
            authCookie = null;
            user = _userName;
            password = _password;
            authority = _domain;
            return true;
        }
    }
}